<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
    <script>
        // 1. 求任意个数的和
        function getSum() {
            // arguments == [1, 2, 3];
            var sum = 0;
            for (var i = 0; i < arguments.length; i++) {
                sum += arguments[i];
            }
            return sum;
        }
        console.log(getSum(1, 2, 3));
        console.log(getSum(11, 22, 33, 1));

        // 2. 求任意个数的最大值
        function getMax() {
            // arguments === [1, 2, 3];
            var max = arguments[0];
            for (var i = 1; i < arguments.length; i++) {
                if (max < arguments[i]) {
                    max = arguments[i];
                }
            }
            return max;
        }
        console.log(getMax(1, 2, 3));
        console.log(getMax(11, 22, 33, 1));
    </script>
</head>

<body>

</body>

</html>